package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.common.utils.UserThreadLocal;
import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.dto.ReservationDto;
import com.zzyl.nursing.dto.ReservationPageReqDto;
import com.zzyl.nursing.service.IReservationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 预约信息Controller
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/member/reservation")
@Api(tags = "预约信息相关接口")
public class MemberReservationController extends BaseController {
    @Autowired
    private IReservationService reservationService;
    @GetMapping("/cancelled-count")
    @ApiOperation("查询取消预约数量")
    public R<Integer> getCancelledReservationCount() {
        return R.ok(reservationService.getCancelledReservationCount());
    }
    @GetMapping("/countByTime")
    @ApiOperation("查询每个时间段剩余预约次数")
    public R countByTime(Long time){
        return R.ok(reservationService.countByTime(time));
    }

    @PostMapping
    @ApiOperation("新增预约信息")
    public AjaxResult addReservation(@RequestBody ReservationDto dto) {
        reservationService.addReservation(dto);
        return success();
    }
    @GetMapping("/page")
    @ApiOperation("分页查询预约信息")
    public R pageQuery(ReservationPageReqDto dto){
        TableDataInfo<Reservation> tableDataInfo = reservationService.pageQuery(dto);
        return R.ok(tableDataInfo);
    }
}